package ru.michaeltyan.familyconnector.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import ru.michaeltyan.familyconnector.beans.User;
import ru.michaeltyan.familyconnector.dao.UserDao;

public class UserDaoImpl extends HibernateDaoSupport implements UserDao {

	public void save(User user) {
		getHibernateTemplate().save(user);
	}

	public void update(User user) {
		getHibernateTemplate().update(user);

	}

	public void delete(User user) {
		getHibernateTemplate().delete(user);

	}

	public User findByLogin(String login) {
		@SuppressWarnings("rawtypes")
		List users = getHibernateTemplate().find("from User where login=?", login);
		if (users != null && users.size() > 0) {
			return (User) users.get(0);
		} else {
			return null;
		}
	}

}
